<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 异步编程的一种解决方案

    var p = new Promise(function(resolve,reject){
        // 回调函数 => 容器 => 可以在容器中执行异步代码
        setTimeout(()=>{
            // resolve(true);
            reject(false);
            console.log("2222",p);
        },1000);
    })
    console.log(11111,p); // {PromiseState:"pending",PromiseResult:undefined}

    // p.then(function(arg){
    //     console.log("fulfilled",arg);
    // },function(arg){
    //     console.log("rejected",arg);
    // })

    p.then(function(arg){
        console.log("fulfilled",arg);
    }).catch(function(arg){
        console.log("rejected",arg);
    })


</script>
</html>